// ... existing code ...
Component({
  properties: {
    icon: { type: String, value: '' },
    text: { type: String, value: '' },
    url: { type: String, value: '' },
    // 添加缓存参数
    cacheKey: { type: String, value: '' }
  },
  methods: {
    navigateToUrl() {
      if (this.data.url) {
        // 判断是否为tabBar页面
        const tabBarUrls = ['/pages/index/index', '/pages/services/services', '/pages/community/community', '/pages/management/management', '/pages/profile/profile'];
        const urlPath = this.data.url.split('?')[0];

        if (tabBarUrls.includes(urlPath)) {
          wx.switchTab({
            url: this.data.url,
            success: () => {
              console.log('切换tab成功:', this.data.url);
            },
            fail: (err) => {
              console.error('切换tab失败:', err);
              wx.showToast({
                title: '跳转失败',
                icon: 'none'
              });
            }
          });
        } else {
          wx.redirectTo({
            url: this.data.url,
            success: () => {
              console.log('跳转成功:', this.data.url);
            },
            fail: (err) => {
              console.error('跳转失败:', err);
              wx.showToast({
                title: '跳转失败',
                icon: 'none'
              });
            }
          });
        }
      }
    }
  },
  // 组件生命周期优化
  lifetimes: {
    attached() {
      // 可以在这里添加一些初始化逻辑
    },
    detached() {
      // 清理不必要的缓存
      if (this.data.cacheKey) {
        try {
          wx.removeStorageSync(this.data.cacheKey);
        } catch (e) {
          console.error('清理缓存失败:', e);
        }
      }
    }
  }
})
// ... existing code ...